import {request} from '@umijs/max';
import * as API from "@/services";


/** 期刊分期 分页检索请求 */
export async function queryJournalPeriods(params?: API.JournalPeriodPageQueryParams): Promise<API.RespPageResult<API.JournalPeriod>> {
  return request('/api/v1/journal-period', {
    params,
  });
}

/** 期刊分期 详情请求 */
export async function queryJournalPeriod(bizId: API.EntityId): Promise<API.RespResult<API.JournalPeriod>> {
  return request(`/api/v1/journal-period/${bizId}`);
}

/** 期刊分期 创建请求 */
export async function createJournalPeriod(entity: API.JournalPeriod_Create): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-period`, {
    method: 'POST',
    data: entity,
  });
}

/** 期刊分期 修改请求 */
export async function modifyJournalPeriod(entity: API.JournalPeriod_Modify): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-period/${entity.id}`, {
    method: 'PUT',
    data: entity,
  });
}

/** 期刊分期 修改(部分)请求 */
export async function patchJournalPeriod(entity: API.JournalPeriod_Patch): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-period/${entity.id}`, {
    method: 'PATCH',
    data: entity,
  });
}

/** 期刊分期 删除请求 */
export async function deleteJournalPeriod(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-period/${bizId}`, {
    method: 'DELETE',
  });
}

/** 期刊分期 批量删除请求 */
export async function deleteJournalPeriods(bizIds: API.EntityId[]): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-period`, {
    method: 'DELETE',
    data: {
      ids: bizIds,
    },
  });
}
/**
 * 下载PDF(权限检查)
 */
export async function preCheckJournalPeriodDownload(bizId: API.EntityId, opts?: API.AxiosRequestOpts): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/front/journal-period/${bizId}/pdf/pre-check`, {
    method: "POST",
    ...(opts || {}),
  });
}
